package com.yh.patterns.factory.before;

import com.yh.patterns.factory.before.impl.AmericanCoffee;
import com.yh.patterns.factory.before.impl.LatteCoffee;

/**
 * @Auther:云尚学Java
 * 咖啡店类
 */
public class CoffeeStore {
    public Coffee orderCoffee(String type){
        //1.声明Coffee类型的变量，根据不同类型创建不同的coffee子类对象
        Coffee coffee=null;
        if("american".equals(type)){
            coffee=new AmericanCoffee();
        }else if("latte".equals(type)){
            coffee=new LatteCoffee();
        }else {
            throw new RuntimeException("对不起，您点的咖啡不存在");
        }
        //2.加配料
        coffee.addSugar();
        coffee.addMilk();
        return coffee;
    }
}
